package demo;

import java.util.*;

// Java中简单方法使用，矩阵、异常
public class Test {
    public static void main1(String[] args) {
        String s1 = "hEllo";
        System.out.println(s1.toUpperCase());

        System.out.println(s1.toLowerCase());

        for(int i = 0 ;i < s1.length(); i++){
            char ch = s1.charAt(i);
            System.out.println(ch);
        }

        char[] chars = s1.toCharArray();
        for(int i = 0; i < chars.length ;i++){
            System.out.println(chars[i]);
        }


        String s2 = "HelloWorld";
        String sx = s2.replaceAll("ld","xx");
        System.out.println(sx);


        String s3 = "My name is LiHua";
        String[] strings = s3.split(" ");
        for(int i=0; i<strings.length ; i++){
            System.out.println(strings[i]);
        }


        String s4 = "all over the world";
        String sz = s4.substring(4,8);
        System.out.println(sz);

    }

    public static void main2(String[] args){
        Scanner in = new Scanner(System.in);
        int row1,col1,row2,col2;

        row1 = in.nextInt();
        col1 = in.nextInt();
        int[][] matrix1 = new int[row1][col1];
        for(int i = 0; i < row1; i++){
            for(int j = 0; j < col1; j++){
                matrix1[i][j] = in.nextInt();
            }
        }

        row2 = in.nextInt();
        col2 = in.nextInt();
        int[][] matrix2 = new int[row2][col2];
        for(int i = 0; i < row2; i++){
            for(int j = 0; j < col2; j++){
                matrix2[i][j] = in.nextInt();
            }
        }

        int[][] ret = multiply(matrix1,row1,col1,matrix2,row2,col2);
        for(int i = 0; i<row1; i++){
            for(int j = 0; j < col2; j++){
                System.out.print(ret[i][j]+" ");
            }
            System.out.println();
        }
    }


    public static int[][] multiply(int[][] a,int row1,int col1, int[][] b, int row2, int col2){
        int[][] ret = new int[row1][col2];

        for(int j = 0; j < col2; j++){
            for(int i = 0; i < row1; i++){
                int sum = 0;
                for(int k = 0; k < col1; k++){
                    sum += a[i][k]*b[k][j];
                }
                ret[i][j] = sum;
            }
        }
        return ret;
    }


    public static void main(String[] args){
        int[] arr = {1,3,7,4,5,9};
        Arrays.sort(arr);
        for(int a : arr){
            System.out.print(a+" ");
        }
    }
}


class People{
    private int age = 1;
    public void setAge(int age) throws IntegerException {
        this.age = age;
        if(age>120){
            throw new IntegerException("too old");
        }else if(age<0){
            throw new IntegerException("illegal input");
        }
    }
    public int getAge(){
        return age;
    }
}

class IntegerException extends Exception {
    String a;

    public IntegerException(){

    }
    public IntegerException(String a){
        this.a=a;
    }
    public String toString(){
        return a;
    }
}


class StringList{
    LinkedList<String> constructList(String[] strs){
        LinkedList<String> st = new LinkedList<>();
        for(int i = 0; i < strs.length; i++){
            st.add(strs[i]);
        }
        return st;
    }

    String search(LinkedList<String> list){
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        for(int i = 0; i < list.size(); i++){
            if(num == list.get(i).length()){
                return list.get(i);
            }
        }
        return "not exist";
    }
}
